﻿//
//  Copyright (c) 2011 Extreme: Paweł Huryn (lead), Jakub Domański
//

using System;
using System.ComponentModel;
using System.Web.UI.WebControls;

namespace Extreme.SPFramework.WebControls
{
    /// <summary>
    /// Renders as label in Disabled mode
    /// </summary>
    public class CustomDropDownList : DropDownList
    {
        [Browsable(true)]
        [Category("Appearance")]
        [Description("Renders control as string if disabled")]
        public bool RenderAsStringIfDisabled { get; set; }

        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            if (this.Enabled || !RenderAsStringIfDisabled)
                base.Render(writer);
            else
                writer.Write(base.SelectedItem != null ? (base.SelectedItem.Text ?? String.Empty) : String.Empty);
        }
    }
}
